home *** CD-ROM | disk | FTP | other *** search
/ PC Media 2 / PC MEDIA CD02.iso / share / prog / pb_menu / menusys.txt < prev    next >
Encoding:
Text File  |  1993-06-10  |  10.8 KB  |  314 lines

  1. Menusys Menuing System
  2. Text-Mode GUI for Power BASIC 3.0
  3. Version 1.0A
  4.  
  5. (C) Copyright 1993 by Tim Gerchmez
  6. ----------------------------------
  7.  
  8.  
  9.               ** Sub and Function Reference **
  10.  
  11.  
  12. Total Routines: 24
  13. -----------------------------------------------------------------------------
  14. * FUNCTION altkey%
  15.  
  16. This function returns the state of the ALT key.  It will return one
  17. if the ALT key is pressed, or zero if it isn't.
  18.  
  19. Example: IF altkey% <> 0 THEN PRINT "ALT Key Pressed!"
  20.  
  21. -----------------------------------------------------------------------------
  22. * SUB dopcopyfrom
  23.  
  24. This routine copies the page zero text screen to page
  25. one, turning off the mouse first if necessary.
  26.  
  27. Example: CALL dopcopyfrom
  28.  
  29. -----------------------------------------------------------------------------
  30. * SUB dopcopyto
  31.  
  32. This routine copies the text screen at page one back
  33. to page zero, turning off the mouse first if necessary.
  34.  
  35. Example: CALL dopcopyto
  36.  
  37. -----------------------------------------------------------------------------
  38. * SUB drawbox (yd%, xd%, tpe%, shadow%, title$)
  39.  
  40. Draws a box with the upper left corner at the current cursor
  41. position.
  42.  
  43. yd% / xd% = Y and X dimensions of the box desired
  44.  
  45. tpe% = border type:
  46. 0 = no border
  47. 1 = single border
  48. 2 = double border
  49.  
  50. shadow% = shadow type:
  51. 0 = no shadow
  52. 1 = left shadow
  53. 2 = right shadow
  54.  
  55. title$ = title for box (set to "" for none)
  56.  
  57. Example: LOCATE 1,1
  58.      CALL drawbox(10, 10, 1, 2, "This is a box")
  59.  
  60. ------------------------------------------------------------------------------
  61. * SUB findfile (fi$, yn%)
  62.  
  63. Searches for the specified path\file in fi$.  If not
  64. found, yn% = 0, else yn% = 1.
  65.  
  66. example: INPUT "Filename ";fi$
  67.      call findfile(fi$, yn%)
  68.      if yn% = 0 then print "File Not Found"
  69.  
  70. -----------------------------------------------------------------------------
  71. * SUB mcheck
  72.  
  73. Checks current position of mouse cursor and state of buttons
  74. and updates the corresponding global variables msy%, msx%, lb%
  75. and rb% (for lb% and rb%, 1 = pressed, 0 = not pressed).
  76.  
  77. msy% = y coordinates of mouse cursor (1-25)
  78. msx% = x coordinates of mouse cursor (1-80)
  79. lb% = left button
  80. rb% = right button
  81.  
  82. Example: CALL mcheck
  83.  
  84. -----------------------------------------------------------------------------
  85. * SUB MENUSYS (menu$(), help$(), menucount%(), menutype%(), topchoice%, bottomchoice%)
  86.  
  87. Displays a pull-down menu at the top of the screen.  DIM menu$
  88. (topcount%, bottomcount%), help$(topcount%, bottomcount%),
  89. menutype%(topcount%, bottomcount%).  Topcount% should correspond
  90. to the number of top (bar) menu choices available, and bottomcount%
  91. to the MAXIMUM number of bottom menu choices available.
  92.  
  93. topchoice% and bottomchoice% will be returned, corresponding to the top
  94. (bar) and bottom (box) menu choices selected by the user.  If the user
  95. presses ESC, bottomchoice% will equal zero.
  96.  
  97. * This is the "main" routine in the MENUSYS Library,
  98. * and the one routine that calls most of the others.
  99.  
  100. Menu Types (for menutype%):
  101. 0 = Available (normal)
  102. 1 = Unavailable (cannot be selected)
  103. 2 = Bullet On
  104. 3 = Bullet Off
  105.  
  106. Use Function ALTKEY in a separate program to determine if the ALT key
  107. is pressed (to call this routine) and/or use the mouse routines to
  108. determine if the mouse cursor is in the top row and proper column
  109. to call this routine.  If not using ALTKEY or mouse cursor to call
  110. MENUSYS, you can set topchoice% to the starting choice number for
  111. the top menu before calling (defaults to menu option one).
  112.  
  113. Menu Selection Columns (for each top item):
  114. 1 = 1-10       2 = 11-20       3 = 21-30       4 = 31-40
  115. 5 = 41-50      6 = 51-60       7 = 61-70       8 = 71-80
  116.  
  117. Example: CALL menusys(menu$(), help$(), menucount%(), menutype%(), topch%, botch%)
  118.      PRINT "You Chose ";topch%; botch%
  119.  
  120. -----------------------------------------------------------------------------
  121. * SUB mhardreset (ms%, nb%)
  122.  
  123. Checks status of mouse and resets if present.  Use this routine
  124. at the beginning of a program to check for the presence of a mouse
  125. and to reset it if present.
  126. Returns ms% = -1 and nb% = number of buttons if mouse driver present
  127. and reset, otherwise ms% = 0.
  128.  
  129. Example: CALL mhardreset(ms%, nb%)
  130.      IF ms%<>0 then print "Mouse Found, with ";nb%;" buttons."
  131.  
  132. -----------------------------------------------------------------------------
  133. * SUB mhide
  134.  
  135. Makes the mouse cursor invisible, and decrements the internal
  136. mouse cursor flag by one.
  137.  
  138. Example: IF mouse% <> 0 THEN CALL mhide
  139.  
  140. -----------------------------------------------------------------------------
  141. * SUB mscrolldown (nls%, uly%, ulx%, lry%, lrx%, atrb%)
  142.  
  143. Scrolls a portion of the text screen down, turning the mouse
  144. cursor off first if necessary.  Set uly% and ulx% to the
  145. coordinates for the upper left corner of the area to scroll,
  146. and lry% and lrx% to the lower right corner of the area to
  147. scroll.  Set atrb% to the attribute to scroll into the blank
  148. area.  nls% = number of lines to scroll down (if 0, the entire
  149. area is blanked).
  150.  
  151. Example: CALL mscrolldown(1, 1, 1, 25, 80, 7)
  152.  
  153. -----------------------------------------------------------------------------
  154. * SUB mscrollup (nls%, uly%, ulx%, lry%, lrx%, atrb%)
  155.  
  156. Scrolls a portion of the text screen up, turning the mouse
  157. cursor off first if necessary.  Set uly% and ulx% to the
  158. coordinates for the upper left corner of the area to scroll,
  159. and lry% and lrx% to the lower right corner of the area to
  160. scroll.  Set atrb% to the attribute to scroll into the blank
  161. area.  nls% = number of lines to scroll up (if 0, the entire
  162. area is blanked).
  163.  
  164. Example: CALL mscrollup(1, 1, 1, 25, 80, 7)
  165.  
  166. -----------------------------------------------------------------------------
  167. * SUB mshow
  168.  
  169. Increments the internal mouse cursor flag, and if flag = 0, makes
  170. the mouse cursor visible.  Flag defaults to -1 when driver is reset,
  171. so this function will usually make the cursor visible on the screen.
  172.  
  173. Example: CALL mshow
  174.  
  175. -----------------------------------------------------------------------------
  176. * SUB mwaitrelease
  177.  
  178. Waits for Left/Right Mouse Button to be Released.
  179.  
  180. Example: CALL mwaitrelease
  181.  
  182. ------------------------------------------------------------------------------
  183. * sub pagecopy(source%, dest%)
  184.  
  185. This routine copies the screen page specified in source% to the page
  186. specified in dest%, and is called by dopcopyfrom and dopcopyto to
  187. save/restore the current text screen.
  188.  
  189. This is a text-mode only imitation of the
  190. QuickBASIC/QBASIC PCOPY command.
  191.  
  192. Example: CALL pagecopy(1, 0)
  193.  
  194. -----------------------------------------------------------------------------
  195. * SUB printbottomhelp (hlp$)
  196.  
  197. Internal routine used by Menusys, but can be used externally as well.
  198. Displays the line of help text in hlp$ on the bottom of the screen.
  199. Blanks the bottom screen line if hlp$ = "-". To skip print, set hlp$
  200. to "".
  201.  
  202.  
  203. Example: hlp$="Press F1 for Help"
  204.      CALL printbottomhelp(hlp$)
  205.  
  206. -----------------------------------------------------------------------------
  207. * SUB readhelp (topchoice%, bottomchoice%)
  208.  
  209. A routine to display context-sensitive help.  Utilized by MENUSYS but can
  210. also be called externally.  The global variable HELPFN$ should be set to
  211. the path\filename of the help file, and PROGNAME$ to the name of the program
  212. that the help is for.  The format of the help files in MENUSYS is:
  213.  
  214. [1/1]
  215.  
  216. HELP TEXT
  217.  
  218. ~~~
  219. [1/2]
  220.  
  221. HELP TEXT
  222.  
  223. ~~~
  224. [1/3]
  225.  
  226. HELP TEXT
  227.  
  228. ~~~
  229.  
  230. The top and bottom menu entries for the help item desired should be in
  231. topchoice% and bottomchoice% before calling.  Notice that each help entry
  232. in the help file has the top/bottom menu entries defined in square brackets,
  233. followed immediately by the help text.  At the end of the help text for each
  234. menu item, there are three tildes in a row.  There can be an unlimited
  235. number of help items in each help file, as long as they follow the above
  236. format (see the example help file included with MENUSYS).  If you use
  237. [0/0] or any other numbers that don't fall in the area of the top/bottom
  238. menu entries, you can call readhelp from the main program to display help
  239. on other program options.  For example, you could CALL READHELP(0,0) and
  240. have a [0/0] entry in your help file.
  241.  
  242. If you don't want MENUSYS to display help for the various pulldown menu
  243. items, just set HELPFN$ to "" before calling.  Also, if READHELP doesn't
  244. find the help file indicated in HELPFN$, it won't crash but it won't
  245. display any help either.  If it finds the help file but not the entry
  246. specified in topchoice%/bottomchoice%, it will display "NO HELP AVAILABLE
  247. FOR THIS MENU ENTRY."
  248.  
  249. Example: PRINT "You Pressed F1!"
  250.      CALL readhelp(0, 0)
  251.  
  252. -----------------------------------------------------------------------------
  253. * SUB readscreen (y%, x%, ch%, atr%, fgd%, bkg%)
  254.  
  255. A routine to read the contents of the screen at the Y (1-25) and X
  256. (1-80) coordinates specified in y% and x%.  The character at the screen
  257. position specified will be returned in ch%, the attribute value in atr%,
  258. the foreground color in fgd%, and the background color in bkg%.
  259.  
  260. Example: CALL readscreen(1, 1, ch%, atr%, fgd%, bkg%)
  261.  
  262. -----------------------------------------------------------------------------
  263. * FUNCTION vidseg&
  264.  
  265. A function to return the correct video segment.  VIDSEG& will equal
  266. &hb800 if color or &hb000 if a monochrome monitor is detected.  These
  267. values can then be used with DEF SEG and an offset to access video
  268. (text) memory directly.
  269.  
  270. Example: IF vidseg& = &Hb800 then print "Color"
  271.  
  272. -----------------------------------------------------------------------------
  273. * SUB writescreen (y%, x%, ch%, atr%, fgd%, bkg%)
  274.  
  275. A routine to store a certain value at a specified screen location.  Set y%
  276. and x% to the Y and X screen coordinates desired, ch% to the character to
  277. store.  Then either set atr% to 0 and fgd% and bkg% to the desired
  278. foreground/background colors, or set atr% to the desired attribute and
  279. ignore the values of fgd% and bkg%, and call this routine.
  280.  
  281. Example: CALL writescreen(1, 1, 32, 0, 7, 1)
  282.  
  283. -----------------------------------------------------------------------------
  284. Internal Routines used by function MENUSYS:
  285.  
  286. * SUB bottomdehilight (top%, bottom%, menu$(), menutype%())
  287.  
  288. This is an internal routine used by MENUSYS to dehighlight
  289. box menu options.
  290.  
  291.  
  292. * SUB bottomhilight (top%, bottom%, menu$(), menutype%())
  293.  
  294. This is an internal routine used by MENUSYS to highlight
  295. box menu options.
  296.  
  297.  
  298. * SUB printbottommenu (top%, menu$(), menucount%(), menutype%(), bcheck$)
  299.  
  300. An internal routine used by MENUSYS to display the bottom (box) menus.
  301.  
  302.  
  303. * SUB printtopmenu (menu$(), hilight%)
  304.  
  305. An internal routine used by MENUSYS to display the top (bar) menu.
  306.  
  307.  
  308. * SUB tophilight (top%, hilight%, menu$())
  309.  
  310. An internal routine used by MENUSYS to highlight entries on the top
  311. (bar) menu.
  312.  
  313. -----------------------------------------------------------------------------
  314.